package com.rs.game.player.content.warriorsguild;

import com.rs.game.item.Item;
import com.rs.game.player.Player;

public class Defender {
	
	public static boolean containsItem(Player player, int id) {
		Item item = new Item(id);
		return containsItem(player, item);
	}

	public static boolean hasDefender(Player player) {
		if (containsItem(player, 8844) || containsItem(player, 8845)
				|| containsItem(player, 8846) || containsItem(player, 8847)
				|| containsItem(player, 8848) || containsItem(player, 8849)
				|| containsItem(player, 8850) || containsItem(player, 20072)) {
			return true;
		}
		return false;
	}

	public static Item getDefender(Player player) {
		int id = 8844;
		if (containsItem(player, 8850) || containsItem(player, 20072)) {
			id = 20072;
		} else if (containsItem(player, 8849) || containsItem(player, 8850)) {
			id = 8850;
		} else if (containsItem(player, 8848)) {
			id = 8849;
		} else if (containsItem(player, 8847)) {
			id = 8848;
		} else if (containsItem(player, 8846)) {
			id = 8847;
		} else if (containsItem(player, 8845)) {
			id = 8846;
		} else if (containsItem(player, 8844)) {
			id = 8845;
		} else {
			id = 8844;
		}
		return new Item(id);
	}

	public static boolean containsItem(Player player, Item item) {
		return player.getInventory().getItems()
				.contains(new Item(item.getId(), 1))
				|| player.getEquipment().getItems()
						.contains(new Item(item.getId(), 1));
	}

}
